package com.lanyam.travel.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lanyam.travel.base.dao.LineGoodsMapper;
import com.lanyam.travel.base.entity.LineGoods;
import com.lanyam.travel.base.entity.ScenicHotel;
import com.lanyam.travel.base.service.ILineGoodsService;
import com.lanyam.travel.base.service.IScenicHotelService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author rosson
 * @since 2020-01-27
 */
@Service
public class LineGoodsServiceImpl implements ILineGoodsService {

	@Autowired
	private LineGoodsMapper lineGoodsMapper;
	
	@Autowired
	private IScenicHotelService scenicHotelService;
	
	@Override
	public void addLineGoods(LineGoods lineGoods) {
		// TODO Auto-generated method stub
		lineGoodsMapper.insert(lineGoods);
	}

	@Override
	public List<ScenicHotel> queryGoodsOnLine(String lineId) {
		// TODO Auto-generated method stub
		List<String> scenicIds = lineGoodsMapper.queryScenicOnLine(lineId);
		List<ScenicHotel> scenicList = scenicHotelService.batchQueryScenics(scenicIds);
		return scenicList;
	}

	@Override
	public void deleteAllByLineId(String lineId) {
		// TODO Auto-generated method stub
		QueryWrapper<LineGoods> wrapper = new QueryWrapper<LineGoods>();
		wrapper.eq("line_id", lineId);
		lineGoodsMapper.delete(wrapper);
	}

	@Override
	public void deleteLineGoodsById(String id) {
		// TODO Auto-generated method stub
		lineGoodsMapper.deleteById(id);
	}

}
